<!-- 编辑弹窗 -->
<template>
    <ele-modal
      width="40%"
      :movable="false"
      :visible="visible"
      :close-on-click-modal="true"
      custom-class="ele-dialog-form"
      :title="isUpdate ? '汇率设置记录' : '汇率设置记录'"
      @update:visible="updateVisible"
    >
    <div class="ele-body">
      <el-card>
        <ele-pro-table ref="table"  row-key="id" :columns="rateRecordColumns" :need-page="false" :datasource="datasource" :height="tableHeight" :full-height="tableFullHeight">
        </ele-pro-table>
      </el-card>
    </div>
    </ele-modal>
  </template>
  <script>

  //初始化对像

  import { QueryRatelogByCondition } from '@/api/basicdatamanager/ratemanager';
  export default {
    name: 'RateRecord',
    props: {
      // 弹窗是否打开
      visible: Boolean,
      // 修改回显的数据
      data: Object,
    },
    data() {
      return {
        // 表单数据
        form: {},
        fixedHeight:true,
        // 提交状态
        loading: false,
        // 是否是修改
        isUpdate: false,
        // 表格列配置
        rateRecordColumns: [
          {columnKey: 'index', type: 'index', width: 50, align: 'center', showOverflowTooltip: true, fixed: 'left', label:'序号',},
          {prop: 'scurrencyDesc', label: '货币兑',showOverflowTooltip: true, align: 'center',},
          {prop: 'ecurrencyDesc', label: '货币换', showOverflowTooltip: true, align: 'center',},
          {prop: 'rate', label: '汇率', showOverflowTooltip: true, align: 'center',},
          {prop: 'createUserName', label: '创建人', showOverflowTooltip: true, align: 'center',},
          {
            prop: 'createDate', label: '创建时间', width:'155px', showOverflowTooltip: true, align: 'center',
            formatter: (row, column, cellValue) => {return this.$util.toDateString(cellValue,"YYYY-MM-DD HH:mm:ss");}
          },
        ],
      };
    },
    computed: {
        // 表格高度
        tableHeight() {
          var fh = this.fixedHeight ? 'calc(100vh - 400px)' : void 0;
          return fh;
        },
        // 表格全屏时高度
        tableFullHeight() {
          var fh =  this.fixedHeight ? 'calc(100vh - 350px)' : null;
          return fh;
        },
      },
    methods: {

      /* 表格数据源 */
      async datasource(params) {

        params.where.pageindex = params.page;
        params.where.pagesize = params.limit;

        let data = await QueryRatelogByCondition(this.data.id);

        return {
            list:data,
            count:data.length,
        };
      },

      /* 更新visible */
      updateVisible(value) {
        //更新父组件中的visible的值
        this.$emit('update:visible', value);
        //更新文件列表对像
      },

      /* 刷新表格 */
      reload(where) {
        if(this.$refs.table){
          this.$refs.table.reload({ where: where });
        }
      },
  },
    
    /* 监听visible属性变化 */
    watch: {
      visible(visible) {
        if (visible) {
          if (this.data && this.data.id) {
            //赋值this.form
            this.form = this.data;
            this.isUpdate = this.data.id !=null && this.data.id !=undefined;
            this.reload();
          } 
        } 
      }
    }
  };
  </script>
    



 